package lib

import (
	"github.com/gin-gonic/gin"
)

func NewServer() *Server {
	app := gin.Default()
	return &Server{app, &RouterGroup{&app.RouterGroup}}
}

type Server struct {
	*gin.Engine
	*RouterGroup
}

func (s *Server) Use(middlewares ...ContextOptionFunc) gin.IRoutes {
	return s.RouterGroup.Use(middlewares...)
}

func (s *Server) Group(relativePath string, handlers ...ContextOptionFunc) *RouterGroup {
	rHandlers := TransHandlerFunc(handlers...)
	return &RouterGroup{s.Engine.Group(relativePath, rHandlers...)}
}
